{% extends "../../../layui/layouts/blank.html" %}

{% block mainbody %}
<div class="view-block">
    <table class="layui-table">
        <tbody>
        <tr>
            <td>上报编号</td>
            <td>{{report.number}}</td>
        </tr>
        <tr>
            <td>药品名称</td>
            <td>{{report.title}}</td>
        </tr>
        <tr>
            <td>药品类别</td>
            <td>{{report.category}}</td>
        </tr>
        <tr>
            <td>风险累及系统-器官</td>
            <td>{{report.risk}}</td>
        </tr>
        <tr>
            <td>上报时间</td>
            <td>{{report.reported_at}}</td>
        </tr>
        <tr>
            <td>上报单位</td>
            <td>{{report.unit}}</td>
        </tr>
        <tr>
            <td>所属地区</td>
            <td>{{report.address}}</td>
        </tr>
        <tr>
            <td>联系电话</td>
            <td>{{report.phone}}</td>
        </tr>
        <tr>
            <td>备注</td>
            <td>{{report.remark}}</td>
        </tr>

        <tr>
            <td>附件</td>
            <td data-preview data-image="http://www.hnsyppjzx.com:9000/annexes/2020/08/06/20200806173500035/annex_0.jpg?1596706644">
                {% for src in report.imgs %}
                <img src="/{{src}}" alt="" style="max-height: 80px">
                {% endfor %}
            </td>
        </tr>
        </tbody>
        <tfoot>
        <tr>
            <td colspan="2" style="text-align: center">
                <a class="layui-btn layui-btn-info layui-btn" yak-event="watch" data-id="{{report.id}}">关注</a>
                <a class="layui-btn layui-btn-danger layui-btn" yak-event="unwatch" data-id="{{report.id}}">不关注</a>
            </td>
        </tr>
        </tfoot>
    </table>
</div>
{% endblock %}

{% block view_event %}
<script>
    var YAK_EVENTS = {
        watch: function (othis, setter, view) {
            var helper = layui.helper, $ax = layui.ax, layer = layui.layer, id = othis.attr('data-id')
            layer.prompt({
                formType: 2,  value: '无',  maxlength: 500,  title: '请输入风险评估'
            }, function (value, index, elem) {
                var url = "/report-watch",
                ajax = new $ax(url, function (res) {
                    layer.close(index)
                    parent.window.location.reload()
                });
                ajax.setMethod('post')
                ajax.setData({comment: value, id: id});
                ajax.send();
            });
        },
        unwatch: function (othis, setter, view) {
            var helper = layui.helper, $ax = layui.ax, layer = layui.layer, id = othis.attr('data-id')
            layer.prompt({
                formType: 2,  value: '无',  maxlength: 500,  title: '请输入风险评估'
            }, function (value, index, elem) {
                var url = "/report-unwatch",
                    ajax = new $ax(url, function (res) {
                        layer.close(index)
                        parent.window.location.reload()
                    });
                ajax.setMethod('post')
                ajax.setData({comment: value, id: id});
                ajax.send();
            });
        }
    }
</script>
{% endblock %}